package com.yami.shop.live.api.linstener;

import com.yami.shop.bean.app.dto.ProductDto;
import com.yami.shop.bean.enums.EnterpriseApplyType;
import com.yami.shop.bean.event.EnterprisePayFailEvent;
import com.yami.shop.bean.event.EnterprisePaySuccessEvent;
import com.yami.shop.bean.event.GetLivingRoomEvent;
import com.yami.shop.bean.model.EnterprisePay;
import com.yami.shop.bean.model.Product;
import com.yami.shop.bean.param.LiveRoomParam;
import com.yami.shop.common.config.Constant;
import com.yami.shop.common.util.Arith;
import com.yami.shop.live.comment.service.LiveRoomProdService;
import com.yami.shop.live.comment.service.LiveRoomService;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 企业支付事件监听
 */
@Component("getLivingRoomListener")
@AllArgsConstructor
public class GetLivingRoomListener {

    private final LiveRoomService liveRoomService;

    @EventListener(GetLivingRoomEvent.class)
    public void getLivingRoomEventHandle(GetLivingRoomEvent event) {
        Product productDto = event.getProductDto();
        // 查询商品包含的所有直播间
        List<LiveRoomParam> liveRoomParams = liveRoomService.getLivingRoomByProdId(event.getProdId());
        productDto.setLiveRoomParams(liveRoomParams);
    }


}
